import 'dart:ui';

import 'package:flutter/material.dart';
import 'res/listData.dart';

class GridViewcount extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("有点f麻烦"),
        ),
        body: HomeContent(),
      ),
    );
  }
}

class HomeContent extends StatelessWidget {
  Widget setData(context, index) {
    return ListTile(
      leading: Image.network(mListData[index]["imageUrl"]),
      title: Text(mListData[index]["title"]),
      subtitle: Text(mListData[index]["author"]),
    );
  }

  // Widget setData() {
  //   GridTile();
  // }

  List<Widget> getData() {
    List<Widget> mList = new List();

    for (var i = 0; i < 20; i++) {
      mList.add(Container(
        alignment: Alignment.center,
        child: Text(
          "woshi",
          style: TextStyle(color: Colors.red, fontSize: 22),
        ),
        color: Colors.blue,
      ));
    }
    return mList;
  }

  @override
  Widget build(BuildContext context) {
    return GridView.count(
      padding: EdgeInsets.all(10),
      crossAxisSpacing: 20.0,
      mainAxisSpacing: 20.0,
      childAspectRatio: 0.7,
      crossAxisCount: 2,
      children: this.getData(),
    );
  }
}
